<?php
namespace Admin\Controller;
use Think\Controller;
/*
后台登录控制器
 */
class LoginController extends CommonController {
    public function index(){

			if (isset($_SESSION['admin_uid'])) {
				
				$this->success('你已登录', U('admin/index/index'));

			}      
			$this->display();
    }

public function checklogin()
{
	// var_dump(I('post.'));
	$password=md5(I('post.password'));
	$username=I('post.username');

	$res=M('admin')->where("username='$username' and password='$password'")->find();
	// var_dump($res);
	if (isset($res)){
				//后台管理封号
		if ($res['status']==1) {
        Reajax(1,"你已被管理停用,请与管理员联系");
    	}
		$_SESSION['admin_uid']=$res['id'];
		$_SESSION['username']=$res['username'];

		$this->log("登录成功");//这个是系统日志记录
		
		Reajax(0,"登录成功");
	}else{
		Reajax(1,"用户或密码不正确");
	}
}
public function out()
{

	session_unset();
	session_destroy();
	$this->success("退出成功",U("admin/login/index"));
		
}





}